package fr.isima.myant;

import java.util.ArrayList;
import java.util.List;

public class Target {
	
	private String name;
	
	private List<Target> dependencies;
	
	private List<Task> tasks;

	public Target(String name, List<Target> dependencies, List<Task> tasks) 
	{
		super();
		setName(name);
		setDependencies(dependencies);
		setTasks(tasks);
	}
	
	public Target() 
	{
		super();
		setName("defaultName");
		dependencies = new ArrayList<Target>();
		tasks = new ArrayList<Task>();
	}
	
	public Target(String pName) 
	{
		super();
		setName(pName);
		dependencies = new ArrayList<Target>();
		tasks = new ArrayList<Task>();
	}
	
	/**
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	public void execute()
	{
		for (Target t : dependencies)
		{
			t.execute();
		}
		System.out.println("execute Target(" + name + ")");
		for (Task t : tasks)
		{
			t.execute();
		}
	}

	public List<Target> getDependencies() {
		return dependencies;
	}

	public void setDependencies(List<Target> dependencies) {
		this.dependencies = dependencies;
	}

	public List<Task> getTasks() {
		return tasks;
	}

	public void setTasks(List<Task> tasks) {
		this.tasks = tasks;
	}
	
}
